home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Development Tools & Languages / • Other Platforms / PCCTS 1.31 / h / ASTBase.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-10  |  2.6 KB  |  82 lines  |  [TEXT/MPS ]

  1. /* Abstract syntax tree
  2.  *
  3.  * SOFTWARE RIGHTS
  4.  *
  5.  * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
  6.  * Set (PCCTS) -- PCCTS is in the public domain.  An individual or
  7.  * company may do whatever they wish with source code distributed with
  8.  * PCCTS or the code generated by PCCTS, including the incorporation of
  9.  * PCCTS, or its output, into commerical software.
  10.  * 
  11.  * We encourage users to develop software with PCCTS.  However, we do ask
  12.  * that credit is given to us for developing PCCTS.  By "credit",
  13.  * we mean that if you incorporate our source code into one of your
  14.  * programs (commercial product, research project, or otherwise) that you
  15.  * acknowledge this fact somewhere in the documentation, research report,
  16.  * etc...  If you like PCCTS and have developed a nice tool with the
  17.  * output, please mention that you developed it using PCCTS.  In
  18.  * addition, we ask that this header remain intact in our source code.
  19.  * As long as these guidelines are kept, we expect to continue enhancing
  20.  * this system and expect to make other tools available as they are
  21.  * completed.
  22.  *
  23.  * ANTLR 1.31
  24.  * Terence Parr
  25.  * Parr Research Corporation
  26.  * with Purdue University and AHPCRC, University of Minnesota
  27.  * 1989-1995
  28.  */
  29.  
  30. #ifndef ASTBase_H
  31. #define ASTBase_H
  32.  
  33. #include <stdio.h>
  34. #include <stdlib.h>
  35. #include "PCCTSAST.h"
  36.  
  37. /*
  38.  * Notes:
  39.  *
  40.  * To specify a copy constructor, subclass one of these classes and
  41.  * give the copy constructor.  For dup(), you must override the inheritance
  42.  * also as this is copying tree nodes.
  43.  */
  44.  
  45. class ASTBase : public PCCTS_AST {
  46. protected:
  47.     ASTBase *_right, *_down;
  48.  
  49. public:
  50.     PCCTS_AST *right()    { return _right; }    // define the SORCERER interface
  51.     PCCTS_AST *down()    { return _down; }
  52.     void setRight(PCCTS_AST *t)    { _right = (ASTBase *)t; }
  53.     void setDown(PCCTS_AST *t)    { _down = (ASTBase *)t; }
  54.  
  55.     ASTBase() { _right = _down = NULL; }
  56.     virtual ~ASTBase() { ; }
  57.     ASTBase *dup();
  58.     void destroy();
  59.     void preorder();
  60.     static ASTBase *tmake(ASTBase *, ...);
  61.     static void link(ASTBase **, ASTBase **, ASTBase **);
  62.     void subchild(ASTBase **, ASTBase **, ASTBase **);
  63.     void subroot(ASTBase **, ASTBase **, ASTBase **);
  64.     virtual void preorder_action() { ; }
  65.     virtual void preorder_before_action() { printf(" ("); }
  66.     virtual void preorder_after_action() { printf(" )"); }
  67. };
  68.  
  69. class ASTDoublyLinkedBase : public ASTBase {
  70. protected:
  71.     ASTDoublyLinkedBase *_left, *_up;
  72.  
  73. public:
  74.     void double_link(ASTBase *left, ASTBase *up);
  75.     ASTDoublyLinkedBase *dup();
  76.     PCCTS_AST *left() { return _left; }
  77.     PCCTS_AST *up() { return _up; }
  78. };
  79.  
  80. class AST;    // announce that this class will be coming along shortly
  81. #endif
  82.